package com.itboye.eweilisten.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.model.TiXingBean;

import java.util.List;

/**
 * Created by Itboye-000018 on 2017/9/21.
 */
public class ScoreTwoAdapter extends BaseAdapter{
    Context context;
    List<TiXingBean.ListInfo.Child> bean;

    public ScoreTwoAdapter(Context context, List<TiXingBean.ListInfo.Child> bean) {
        this.context = context;
        this.bean = bean;
    }

    @Override
    public int getCount() {
        return bean.size();
    }

    @Override
    public Object getItem(int position) {
        return bean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHouder houder;
        if (view == null) {
            houder = new ViewHouder();
            view = LayoutInflater.from(context).inflate(R.layout.item_gridview_chengji, null,false);
            houder.tvName = (TextView) view.findViewById(R.id.tvChengJi);
            view.setTag(houder);
        }else{
            houder = (ViewHouder) view.getTag();
        }
        houder.tvName.setText(position + 1 + "");
        //0对  1错 3漏
        if (bean.get(position).getAnswer_type()!=null){
            if (bean.get(position).getAnswer_type().equals("0")) {
                houder.tvName.setBackgroundResource(R.drawable.text_view_shape);
            } else if (bean.get(position).getAnswer_type().equals("1")) {
                houder.tvName.setBackgroundResource(R.drawable.text_hongse);
            } else if (bean.get(position).getAnswer_type().equals("2")) {
                houder.tvName.setBackgroundResource(R.drawable.text_huangse);
            }
        }
        return view;
    }
    public class ViewHouder {
        TextView tvName;
    }
}
